package com.ttn.student.controller;

import com.ttn.common.core.entity.Result;
import com.ttn.common.core.entity.studentrecord.VocabularyStudyRecordDetails;
import com.ttn.common.core.entity.studentrecord.bo.SaveBatchTestStudyRecordDetailsBO;
import com.ttn.common.core.entity.studentrecord.query.TestStudyRecordQuery;
import com.ttn.student.service.VocabularyStudyRecordDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * (vocabulary_study_record)表控制层
 *
 * @author xxxxx
 */
@RestController
@Slf4j
@RequestMapping("/vocabulary-study-record-details")
public class VocabularyStudyRecordDetailsController {
    /**
     * 服务对象
     */
    @Resource
    private VocabularyStudyRecordDetailsService vocabularyStudyRecordDetailsService;

    /**
     * 词汇学习记录保存
     *
     * @param request
     * @param vocabularyStudyRecordDetails
     * @return
     */
    @PostMapping("/save/vocabulary-study-record-details")
    public Result saveVocabularyStudyRecordDetails(HttpServletRequest request, @RequestBody VocabularyStudyRecordDetails vocabularyStudyRecordDetails) {
        log.info("VocabularyStudyRecordDetailsController saveVocabularyStudyRecordDetails ,参数:{}", vocabularyStudyRecordDetails);
        return vocabularyStudyRecordDetailsService.saveVocabularyStudyRecordDetails(vocabularyStudyRecordDetails);
    }

    /**
     * 查询测试记录
     *
     * @param request
     * @param testStudyRecordQuery
     * @return
     */
    @PostMapping("/query/vocabulary-study-record-details")
    public Result queryVocabularyStudyRecordDetails(HttpServletRequest request, @RequestBody TestStudyRecordQuery testStudyRecordQuery) {

        log.info("VocabularyStudyRecordDetailsController queryVocabularyStudyRecordDetails ,参数:{}", testStudyRecordQuery);
        return vocabularyStudyRecordDetailsService.queryVocabularyStudyRecordDetails(testStudyRecordQuery);
    }

    @PostMapping("/save/vocabulary-study-record-details-batch")
    public Result saveBatchVocabularyStudyRecordDetails(HttpServletRequest request,
                                                        @RequestBody SaveBatchTestStudyRecordDetailsBO saveBatchVocabularyStudyRecordDetailsBO) {
        log.info("VocabularyStudyRecordDetailsController saveBatchVocabularyStudyRecordDetails ,参数:{}", saveBatchVocabularyStudyRecordDetailsBO);
        return vocabularyStudyRecordDetailsService.saveBatchVocabularyStudyRecordDetails(saveBatchVocabularyStudyRecordDetailsBO);
    }
}
